#pragma once

#include"rbTree.h"
namespace XmLife
{
	template<class k>
	class set
	{
		struct SetKeyOfT
		{
			const k& operator()(const k& data)
			{
				return data;
			}
		};
	public:

		typedef typename RBTree<k, k, SetKeyOfT>::iterator iterator;
		typedef typename RBTree<k, k, SetKeyOfT>::const_iterator const_iterator;

		pair<iterator,bool> Insert(const k& data)
		{
			return _t.Insert(data);
		}

		iterator begin()
		{
			return _t.begin();
		}

		iterator end()
		{
			return _t.end();
		}

		const_iterator begin()const
		{
			return _t.begin();
		}


		const_iterator end()const
		{
			return _t.end();
		}

	private:
		RBTree<k, k, SetKeyOfT> _t;
	};


	void test_set()
	{
		set<int> s;

		set<int>::iterator it = s.begin();
		while (it != s.end())
		{
			cout << *it << " ";
			++it;
		}
		cout << endl;

		s.Insert(3);
		s.Insert(2);
		s.Insert(1);
		s.Insert(5);
		s.Insert(3);
		s.Insert(6);
		s.Insert(4);
		s.Insert(9);
		s.Insert(7);


		it = s.begin();
		while (it != s.end())
		{
			cout << *it << " ";
			++it;
		}
		cout << endl;
	}
}